package cn.edu.tsinghua.smxq.mobilecity.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import cn.edu.tsinghua.smxq.mobilecity.po.StockSearch;
import cn.edu.tsinghua.smxq.mobilecity.utils.DBUtils;

public class StockSearchDAO {

	public boolean saveStockSearch(StockSearch stockSearch) throws SQLException {
		boolean success = false;
		Connection conn = DBUtils.Connect();
		PreparedStatement pstmt = conn
				.prepareStatement("INSERT INTO mobilecity.stocksearch(userid,stockid,time) values(?,?,?)");
		pstmt.setInt(1, stockSearch.getUserId());
		pstmt.setInt(2, stockSearch.getStockId());
		pstmt.setTimestamp(3, stockSearch.getTime());
	
		if (pstmt.executeUpdate() == 1) {
			success = true;
		}
		pstmt.close();
		conn.close();
		return success;
	}
}
